//index.js
//获取应用实例
const app = getApp()
// 分享
const getCurrentPagesApi = require('../../utils/common').getCurrentPagesApi;
const host = require('../../config').host
Page({
  data: {
    jiage: [],
    currentTypeId: 1,
    jiageTabs:[],
  },
  //事件处理函数
  bindViewTap: function() {
    wx.navigateTo({
      url: '../logs/logs'
    })
  },
  toBankuai: function (event) {
    console.log(event);
    var typeTid = event.currentTarget.dataset.typetid;
    var typeId = event.currentTarget.dataset.typeid;
  	this.jiages(typeId);
  	this.setData({
      currentTypeId:typeId,
    });
  },
  jiages: function(type) {
    var that = this
    wx.request({
      url: host+'api/index/jiagedetail',
      data: {'id':type},
      success: function(res){
      	console.log(res.data);
        that.setData({
          jiage: res.data
        })
        // WxParse.wxParse('article', 'html', res.data.data, that, 5)
      },
      fail: function(data){
        console.log(data)
      }
    })
  },
  onShareAppMessage: function (res) {
    if (res.from === 'menu') {
      return {
        title: '国数源',
        path: getCurrentPagesApi()
      }
    }
  },
  onLoad: function () {
  	// console.log('ddd');
      this.jiageTabss();
      this.jiages(1);
  },
  jiageTabss: function() {
    var that = this
    wx.request({
      url: host+'api/index/jiagetabs',
      success: function(res){
        that.setData({
          jiageTabs: res.data
        })
      },
      fail: function(data){
        console.log(data)
      }
    })
  },
  getUserInfo: function(e) {
    console.log(e)
    app.globalData.userInfo = e.detail.userInfo
    this.setData({
      userInfo: e.detail.userInfo,
      hasUserInfo: true
    })
  }
})
